<?php
include('./library/conn.php');
$username=$_REQUEST['username'];
$car=$_REQUEST['car'];

$select="select * from usar where username='$username'";
$result=$mysqli->query($select);

if($result->num_rows<1){
    echo '<script>alert("未登录，请先登录")</script>';
    echo '<script>location="../src/html/login.html"</script>';
    $mysqli->close();
    die();
}

$update="update usar set car='$car' where username='$username'";

$res=$mysqli->query($update);
$mysqli->close();
if($res){
    echo '<script>alert("加入购物车成功")</script>';
    echo '<script>location="../src/html/car.html"</script>';
}

?>